package com.rabbit.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rabbit.vo.req.OperLogReq;
import com.rabbit.vo.res.OperLogDetailRes;
import com.rabbit.vo.res.OperLogRes;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.rabbit.db.entity.OperLog;
import com.rabbit.mapper.OperLogMapper;
import com.rabbit.service.OperLogService;
import org.springframework.transaction.annotation.Transactional;

/**
 * <h1>操作日志业务实现类</h1>
 *
 * @author zjw
 * @date 2022/1/21 22:17
 */
@Service
public class OperLogServiceImpl implements OperLogService {

    @Resource
    private OperLogMapper operLogMapper;

    @Override
    public PageInfo<OperLogRes> queryOperLogList(OperLogReq operLogReq) {
        return PageHelper.startPage(operLogReq.getPage(), operLogReq.getLimit())
                .doSelectPageInfo(() -> operLogMapper.queryOperLogList(operLogReq));
    }

    @Override
    public void truncateOperLog() {
        operLogMapper.truncateOperLog();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer batchDelete(OperLogReq operLogReq) {
        return operLogMapper.batchDelete(operLogReq.getOperIds());
    }

    @Override
    public OperLogDetailRes queryDetail(Long operId) {
        return operLogMapper.queryDetail(operId);
    }
}
